/*
 *js实现读取html
 *2018/9/14
 *李闯
 */
function getHtml(callback) {
    var ifm = document.createElement('iframe');
    ifm.style.display = "none";
    ifm.setAttribute("src", "../../template/AddConsignee.html");
    ifm.setAttribute("id", "shop-iframe-swipe");
    document.body.appendChild(ifm);
    //取值
    var ifw = document.getElementById("shop-iframe-swipe").contentWindow;
    var ifboyd; //iframebody中的全部内容
    ifw.onload = function (e) {
        //iframe内部html
        var ifHtml = ifw.document.body.innerHTML;
        var jsList = ifw.document.querySelectorAll("script"); //插入的html的script标签集合
        var styles = ifw.document.querySelectorAll("link"); //插入html的所有样式表
        var moduleClass = ifw.document.body.getAttribute("class");
        //取值
        ifbody = ifw.document.body.innerHTML;
        insertLayer(ifbody, jsList, styles, moduleClass);
    }

    function insertLayer(ifbody, jsList, styles, moduleClass) {
        //创建新元素，把内容加载进去
        var layerBox = document.createElement("div"); //弹窗盒子//
        layerBox.setAttribute("id", "shop-layerBox");
        layerBox.style.width = "0px";
        layerBox.style.height = "0px";
        layerBox.innerHTML = ifbody;
        layerBox.setAttribute("class", moduleClass);
        document.body.appendChild(layerBox);
        //把所有样式表加入到body中
        for (var i = 0; i < styles.length; i++) {
            document.head.appendChild(styles[i]);
            console.log(styles[i]);
        }
        for (var i = 0; i < jsList.length; i++) {
            if (jsList[i].getAttribute("src")) {
                document.head.appendChild(jsList[i]);
            }
        }
        //移除iframe
        var ifm = document.getElementById("shop-iframe-swipe");
        ifm.parentNode.removeChild(ifm);
    }
}